package com.corner.presenter.imp;

import com.corner.model.leancloud.helper.SmsHelper;
import com.corner.presenter.IForgetPasswordPresenter;
import com.corner.presenter.base.BasePresenter;
import com.corner.ui.view.IForgetPasswordView;

import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;

/**
 * Created by Administrator on 2015/7/11，16.56.
 * 描述：
 */
public class ForgetPasswordPresenter extends BasePresenter<IForgetPasswordView> implements IForgetPasswordPresenter {
    @Override
    public void getSmsCode(String phoneNum) {
        view.showLoading(true);
        SmsHelper.getSmsCode(phoneNum, null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() {
            @Override
            public void call(Object o) {
                if (view != null) {
                    view.showLoading(false);
                    view.getSmsSucess();
                }
            }
        }, new Action1<Throwable>() {
            @Override
            public void call(Throwable throwable) {
                if (view != null) {
                    view.showLoading(false);
                    view.getSmsCodeError(throwable.getMessage());
                }
            }
        });
    }
}
